package com.lineage.server.clientpackets;

import com.lineage.echo.ClientExecutor;
import com.lineage.server.datatables.lock.CharacterConfigReading;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.templates.L1Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class C_CharcterConfig extends ClientBasePacket {
  private static final Log _log = LogFactory.getLog(C_CharcterConfig.class);
  
  public void start(byte[] decrypt, ClientExecutor client) {
    try {
      read(decrypt);
      L1PcInstance pc = client.getActiveChar();
      if (pc == null)
        return; 
      int objid = pc.getId();
      int length = readD() - 3;
      byte[] data = readByte();
      L1Config config = CharacterConfigReading.get().get(objid);
      if (config == null) {
        CharacterConfigReading.get().storeCharacterConfig(objid, length, data);
      } else {
        CharacterConfigReading.get().updateCharacterConfig(objid, length, data);
      } 
    } catch (Exception exception) {
    
    } finally {
      over();
    } 
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
